diff options
| author | Armand Philippot <git@armandphilippot.com> | 2022-05-16 12:46:38 +0200 |
|---|---|---|
| committer | Armand Philippot <git@armandphilippot.com> | 2022-05-16 12:46:38 +0200 |
| commit | 2155550fa36a3bc3c8f66e0926530123b4018cd4 (patch) | |
| tree | 1b7472d7ceeb9c95b2c6de6440b48b94405e155e /src/pages/thematique/[slug].tsx | |
| parent | 8a55aa83bd4b64d1d989cb49b7d9c3fdc1cc6ea5 (diff) | |
refactor: use custom hook for breadcrumb items and schema
Diffstat (limited to 'src/pages/thematique/[slug].tsx')
| -rw-r--r-- | src/pages/thematique/[slug].tsx | 22 |
1 files changed, 6 insertions, 16 deletions
diff --git a/src/pages/thematique/[slug].tsx b/src/pages/thematique/[slug].tsx index dd7e80d..13ef0da 100644 --- a/src/pages/thematique/[slug].tsx +++ b/src/pages/thematique/[slug].tsx @@ -1,5 +1,4 @@ import Heading from '@components/atoms/headings/heading'; -import { type BreadcrumbItem } from '@components/molecules/nav/breadcrumb'; import PostsList, { type Post } from '@components/organisms/layout/posts-list'; import LinksListWidget from '@components/organisms/widgets/links-list-widget'; import PageLayout, { @@ -18,6 +17,7 @@ import { getPageLinkFromRawData, getPostMeta, } from '@utils/helpers/pages'; +import useBreadcrumb from '@utils/hooks/use-breadcrumb'; import useSettings from '@utils/hooks/use-settings'; import { GetStaticPaths, GetStaticProps, NextPage } from 'next'; import Head from 'next/head'; @@ -40,21 +40,10 @@ const ThematicPage: NextPage<ThematicPageProps> = ({ const { content, intro, meta, slug, title } = currentThematic; const { articles, dates, seo, topics } = meta; const intl = useIntl(); - const homeLabel = intl.formatMessage({ - defaultMessage: 'Home', - description: 'Breadcrumb: home label', - id: 'j5k9Fe', + const { items: breadcrumbItems, schema: breadcrumbSchema } = useBreadcrumb({ + title, + url: `/thematique/${slug}`, }); - const blogLabel = intl.formatMessage({ - defaultMessage: 'Blog', - description: 'Breadcrumb: blog label', - id: 'Es52wh', - }); - const breadcrumb: BreadcrumbItem[] = [ - { id: 'home', name: homeLabel, url: '/' }, - { id: 'blog', name: blogLabel, url: '/blog' }, - { id: 'thematic', name: title, url: `/thematique/${slug}` }, - ]; const headerMeta: PageLayoutProps['headerMeta'] = { publication: { date: dates.publication }, @@ -152,7 +141,8 @@ const ThematicPage: NextPage<ThematicPageProps> = ({ dangerouslySetInnerHTML={{ __html: JSON.stringify(schemaJsonLd) }} /> <PageLayout - breadcrumb={breadcrumb} + breadcrumb={breadcrumbItems} + breadcrumbSchema={breadcrumbSchema} title={title} intro={intro} headerMeta={headerMeta} |
